package com.bj.zspace.provider.demo;

import com.bj.zspace.api.demo.DemoService;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;

public class Application {

    private static final String REGISTRY_URL = "nacos://127.0.0.1:8848";

    public static void main(String[] args) {
        startWithBootStrap();
    }

    private static void startWithBootStrap() {

        ServiceConfig<DemoServiceImpl> service = new ServiceConfig<>();
        service.setInterface(DemoService.class);
        service.setRef(new DemoServiceImpl());

        DubboBootstrap bootstrap = DubboBootstrap.getInstance();

        RegistryConfig registryConfig = new RegistryConfig("nacos://127.0.0.1:8848");
        registryConfig.setUsername("nacos");
        registryConfig.setPassword("nacos");

        bootstrap.application(new ApplicationConfig("dubbo-demo-api-provider"))
                .registry(registryConfig)
                .protocol(new ProtocolConfig(CommonConstants.TRIPLE, 20880))
                .service(service)
                .start()
                .await();

    }


}
